package system;

import com.bea.common.security.xacml.InvalidParameterException;

import java.io.IOException;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.faces.component.UISelectItems;
import javax.faces.event.ActionEvent;
import javax.faces.event.ValueChangeEvent;
import javax.faces.model.SelectItem;

import javax.management.InstanceNotFoundException;
import javax.management.MBeanException;
import javax.management.ReflectionException;

import oracle.adf.view.rich.component.rich.RichPopup;
import oracle.adf.view.rich.component.rich.data.RichTable;
import oracle.adf.view.rich.component.rich.input.RichInputText;
import oracle.adf.view.rich.component.rich.input.RichSelectManyShuttle;
import oracle.adf.view.rich.component.rich.layout.RichPanelTabbed;
import oracle.adf.view.rich.event.DialogEvent;

import view.common.Utils;

public class SystemUser {

    private ManageUser objWeblogicUser = null;
    private ManageUserAttribute objWeblogicUserAttribute = null;
    private final String ssc = "SSC";
    private RichInputText txtMatKhauReset;


    public SystemUser() {
        super();
        if (Boolean.FALSE.equals(Utils.getElExpression("#{adfFacesContext.postback}"))) {
            getListUsers();
        }
    }

    public void getListUsers() {
        List<Map<String, Object>> lst = new ArrayList<Map<String, Object>>();
        objWeblogicUser = new ManageUser();
        objWeblogicUserAttribute = new ManageUserAttribute();
        String lstUsers;
        try {
            lstUsers = objWeblogicUser.listUsers();
            //System.out.print(lstUsers);
            while (objWeblogicUser.haveCurrent(lstUsers)) {
                String user = objWeblogicUser.getCurrentName(lstUsers);
                boolean isexist = objWeblogicUser.userExists(user);
                
                if (isexist) {
                    String description =
                        objWeblogicUser.getUserDescription(user);
                    //chỉ lấy người dùng của hệ thống SSC
                    Object objUserAttribute =
                        objWeblogicUser.getUserAttributeValue(objWeblogicUserAttribute.connection,
                                                              objWeblogicUserAttribute.service,
                                                              user,
                                                              "employeetype");                  
                    if (objUserAttribute != null) {
                        String employeetype = objUserAttribute.toString();
                        if (employeetype.equals(ssc)) {
                            Map<String, Object> lstTemp =
                                new HashMap<String, Object>();
                            lstTemp.put("0", user);
                            lstTemp.put("1", description);
                            lst.add(lstTemp);
                        }
                    }
                }
                objWeblogicUser.advance(lstUsers);
            }
            ManageWeblogic.close();
            objWeblogicUser = null;
            table.setValue(lst);

        } catch (Exception e) {
            Utils.showMessage(Utils.MSG_ERROR, e.getMessage());
            e.printStackTrace();
        }
    }

    public void popUserInfo(ActionEvent actionEvent) {
        String paramUsername =
            actionEvent.getComponent().getAttributes().get("param").toString();
        Utils.showPopup(getPopupUserInfo());
        try {
            //hien thi thong tin nguoi dung len tab "thong tin nguoi dung"
            userInfoOutPut(paramUsername);
            //hien thi thong tin nhom quyen len tab phan quyen
            List<SelectItem> listSelectItem = new ArrayList<SelectItem>();
            UISelectItems uiSelectItems = new UISelectItems();
            List<Map<String, Object>> listFullGroup = listGroup();
            List<String> listGroupIsMember =
                listGroupIsMember(paramUsername, listFullGroup);

            for (Map<String, Object> str : listFullGroup) {
                SelectItem si = new SelectItem();
                si.setValue(str.get("0"));
                si.setLabel((String)str.get("1"));
                listSelectItem.add(si);
            }
            uiSelectItems.setValue(listSelectItem);
            selectManyShuttle.setValue(listGroupIsMember);
            selectManyShuttle.getChildren().clear();
            selectManyShuttle.getChildren().add(uiSelectItems);
        } catch (Exception e) {
            Utils.showMessage(Utils.MSG_ERROR, e.getMessage());
            e.printStackTrace();
        }
    }
    
    public void popUser(ActionEvent actionEvent) {
        String paramUsername =
            actionEvent.getComponent().getAttributes().get("param").toString();
        Utils.showPopup(getPopup());
        try {
            //hien thi thong tin nguoi dung len tab "thong tin nguoi dung"
            bindingOutPut(paramUsername);
            //hien thi thong tin nhom quyen len tab phan quyen
            List<SelectItem> listSelectItem = new ArrayList<SelectItem>();
            UISelectItems uiSelectItems = new UISelectItems();
            List<Map<String, Object>> listFullGroup = listGroup();
            List<String> listGroupIsMember =
                listGroupIsMember(paramUsername, listFullGroup);

            for (Map<String, Object> str : listFullGroup) {
                SelectItem si = new SelectItem();
                si.setValue(str.get("0"));
                si.setLabel((String)str.get("1"));
                listSelectItem.add(si);
            }
            uiSelectItems.setValue(listSelectItem);
            selectManyShuttle.setValue(listGroupIsMember);
            selectManyShuttle.getChildren().clear();
            selectManyShuttle.getChildren().add(uiSelectItems);
        } catch (Exception e) {
            Utils.showMessage(Utils.MSG_ERROR, e.getMessage());
            e.printStackTrace();
        }
    }


    public void bindingOutPut(String paramUsername) throws InstanceNotFoundException,
                                                           MBeanException,
                                                           ReflectionException,
                                                           IOException,
                                                           Exception {
        objWeblogicUser = new ManageUser();
        objWeblogicUserAttribute = new ManageUserAttribute();

        txtTenDangNhapUpdate.setValue(paramUsername);
        txtChuThichUpdate.setValue(objWeblogicUser.getUserDescription(paramUsername));

        txtDisplaynameUpdate.setValue(objWeblogicUser.getUserAttributeValue(objWeblogicUserAttribute.connection,
                                                                            objWeblogicUserAttribute.service,
                                                                            paramUsername,
                                                                            "displayname"));
        txtMailUpdate.setValue(objWeblogicUser.getUserAttributeValue(objWeblogicUserAttribute.connection,
                                                                     objWeblogicUserAttribute.service,
                                                                     paramUsername,
                                                                     "mail"));
        txtMobileUpdate.setValue(objWeblogicUser.getUserAttributeValue(objWeblogicUserAttribute.connection,
                                                                       objWeblogicUserAttribute.service,
                                                                       paramUsername,
                                                                       "mobile"));
        txtDepartmentnumberUpdate.setValue(objWeblogicUser.getUserAttributeValue(objWeblogicUserAttribute.connection,
                                                                                 objWeblogicUserAttribute.service,
                                                                                 paramUsername,
                                                                                 "departmentnumber"));
        txtTitleUpdate.setValue(objWeblogicUser.getUserAttributeValue(objWeblogicUserAttribute.connection,
                                                                      objWeblogicUserAttribute.service,
                                                                      paramUsername,
                                                                      "title"));

        ManageWeblogic.close();
    }
    public void userInfoOutPut(String paramUsername) throws InstanceNotFoundException,
                                                           MBeanException,
                                                           ReflectionException,
                                                           IOException,
                                                           Exception {
        objWeblogicUser = new ManageUser();
        objWeblogicUserAttribute = new ManageUserAttribute();
        
        txtChuthichInfo.setValue(objWeblogicUser.getUserDescription(paramUsername));

        txtHovatenInfo.setValue(objWeblogicUser.getUserAttributeValue(objWeblogicUserAttribute.connection,
                                                                            objWeblogicUserAttribute.service,
                                                                            paramUsername,
                                                                            "displayname"));
        txtEmailInfo.setValue(objWeblogicUser.getUserAttributeValue(objWeblogicUserAttribute.connection,
                                                                     objWeblogicUserAttribute.service,
                                                                     paramUsername,
                                                                     "mail"));
        txtMobileInfo.setValue(objWeblogicUser.getUserAttributeValue(objWeblogicUserAttribute.connection,
                                                                       objWeblogicUserAttribute.service,
                                                                       paramUsername,
                                                                       "mobile"));
        txtDepartmentInfo.setValue(objWeblogicUser.getUserAttributeValue(objWeblogicUserAttribute.connection,
                                                                                 objWeblogicUserAttribute.service,
                                                                                 paramUsername,
                                                                                 "departmentnumber"));
        txtTitleInfo.setValue(objWeblogicUser.getUserAttributeValue(objWeblogicUserAttribute.connection,
                                                                      objWeblogicUserAttribute.service,
                                                                      paramUsername,
                                                                      "title"));

        ManageWeblogic.close();
    }
    public void changePass(ActionEvent actionEvent) {
        objWeblogicUser = new ManageUser();
        String username = txtTenDangNhapUpdate.getValue().toString();
        String oldPass = (String)txtMatKhauUpdate.getValue();
        String newPass = (String)txtNhapLaiMatKhauUpdate.getValue();
        boolean inputErr = false;
        if (oldPass != null && oldPass != "" && newPass != null &&
            newPass != "") {
            try {
                String txtMatKhau =
                    this.txtMatKhauUpdate.getValue().toString();
                String txtNhapLaiMatKhau =
                    this.txtNhapLaiMatKhauUpdate.getValue().toString();
                if (!validateFieldUpdate(txtMatKhau, txtNhapLaiMatKhau)) {
                    inputErr = true;
                }
                if (!inputErr) {
                    objWeblogicUser.changeUserPassword(username, oldPass,
                                                       newPass);
                    ManageWeblogic.close();
                    Utils.showMessage(Utils.MSG_INFO,
                                      "Đổi mật khẩu thành công.");
                    txtMatKhauUpdate.setValue("");
                    txtNhapLaiMatKhauUpdate.setValue("");
                }
            } catch (MBeanException ex) {
                Utils.showMessage(Utils.MSG_ERROR, "Mật khẩu cũ không đúng.");
                ex.printStackTrace();
            } catch (Exception e) {
                Utils.showMessage(Utils.MSG_ERROR,
                                  "Cập nhật không thành công");
                e.printStackTrace();
            }

        }
    }
    public void resetPass(ActionEvent actionEvent) {
        objWeblogicUser = new ManageUser();
        String username = txtTenDangNhapUpdate.getValue().toString();
        //String oldPass = (String)txtMatKhauUpdate.getValue();
        String newPass = (String)txtMatKhauReset.getValue();
        boolean inputErr = false;
        if ( newPass != null &&
            newPass != "") {
            try {                
                    objWeblogicUser.resetUserPassword(username,newPass);
                    ManageWeblogic.close();
                    Utils.showMessage(Utils.MSG_INFO,
                                      "Đổi mật khẩu thành công.");
                    txtNhapLaiMatKhauUpdate.setValue("");
                           
            } catch (Exception e) {
                Utils.showMessage(Utils.MSG_ERROR,
                                  "Cập nhật không thành công");
                e.printStackTrace();
            }

        }
    }

    public void updateUserAttribute(ValueChangeEvent valueChangeEvent) {

        objWeblogicUser = new ManageUser();
        objWeblogicUserAttribute = new ManageUserAttribute();
        Object newValue = valueChangeEvent.getNewValue();
        String componentId = valueChangeEvent.getComponent().getId();
        String username = txtTenDangNhapUpdate.getValue().toString();
        if (componentId.equals("description")) {
            try {
                objWeblogicUser.setUserDescription(username, (String)newValue);
            } catch (Exception e) {
                Utils.showMessage(Utils.MSG_ERROR, e.getMessage());
                e.printStackTrace();
            }
        }
        if (componentId.equals("displayname")) {
            try {
                objWeblogicUser.setUserAttributeValue(objWeblogicUserAttribute.connection,
                                                      objWeblogicUserAttribute.service,
                                                      username, "displayname",
                                                      newValue);
            } catch (Exception e) {
                Utils.showMessage(Utils.MSG_ERROR, e.getMessage());
                e.printStackTrace();
            }
        }
        if (componentId.equals("mail")) {
            try {
                objWeblogicUser.setUserAttributeValue(objWeblogicUserAttribute.connection,
                                                      objWeblogicUserAttribute.service,
                                                      username, "mail",
                                                      newValue);
            } catch (Exception e) {
                Utils.showMessage(Utils.MSG_ERROR, e.getMessage());
                e.printStackTrace();
            }
        }
        if (componentId.equals("phone")) {
            try {
                objWeblogicUser.setUserAttributeValue(objWeblogicUserAttribute.connection,
                                                      objWeblogicUserAttribute.service,
                                                      username, "mobile",
                                                      newValue);
            } catch (Exception e) {
                Utils.showMessage(Utils.MSG_ERROR, e.getMessage());
                e.printStackTrace();
            }
        }
        if (componentId.equals("department")) {
            try {
                objWeblogicUser.setUserAttributeValue(objWeblogicUserAttribute.connection,
                                                      objWeblogicUserAttribute.service,
                                                      username,
                                                      "departmentnumber",
                                                      newValue);
            } catch (Exception e) {
                Utils.showMessage(Utils.MSG_ERROR, e.getMessage());
                e.printStackTrace();
            }
        }
        if (componentId.equals("title")) {
            try {
                objWeblogicUser.setUserAttributeValue(objWeblogicUserAttribute.connection,
                                                      objWeblogicUserAttribute.service,
                                                      username, "title",
                                                      newValue);
            } catch (Exception e) {
                Utils.showMessage(Utils.MSG_ERROR, e.getMessage());
                e.printStackTrace();
            }
        }
        //giai phong bo nho
        ManageWeblogic.close();
        objWeblogicUser = null;
        objWeblogicUserAttribute = null;
    }


    public void resetFormValue() {
        this.txtTenDangNhap.setValue("");
        this.txtChuThich.setValue("");
        this.txtMatKhau.setValue("");
        this.txtNhapLaiMatKhau.setValue("");
        this.txtDisplayname.setValue("");
        this.txtMail.setValue("");
        this.txtMobile.setValue("");
        this.txtDepartmentnumber.setValue("");
        this.txtTitle.setValue("");
    }


    public List<Map<String, Object>> listGroup() throws InstanceNotFoundException,
                                                        MBeanException,
                                                        ReflectionException,
                                                        IOException {
        List<Map<String, Object>> lst = new ArrayList<Map<String, Object>>();
        ManageGroup objWeblogicGroup = new ManageGroup();
        String listGroup;

        listGroup = objWeblogicGroup.listGroups();
        EnumHeThong.enumPagePermission[] lstEnumGroup =
            EnumHeThong.enumPagePermission.values();
        List<String> listPagePer = new ArrayList<String>();
        for (int i = 0; i < lstEnumGroup.length; i++) {
            listPagePer.add(lstEnumGroup[i].getPermissionCode());
        }
        while (objWeblogicGroup.haveCurrent(listGroup)) {
            String group = objWeblogicGroup.getCurrentName(listGroup);
            String description = objWeblogicGroup.getGroupDescription(group);
            objWeblogicGroup.advance(listGroup);
            if (listPagePer.contains(group)) {
                Map<String, Object> lstTemp = new HashMap<String, Object>();
                lstTemp.put("0", group);
                lstTemp.put("1", description);
                lst.add(lstTemp);
            }
        }
        ManageWeblogic.close();
        return lst;
    }

    public List<String> listGroupIsMember(String username,
                                          List<Map<String, Object>> listGroup) throws InstanceNotFoundException,
                                                                                      MBeanException,
                                                                                      ReflectionException,
                                                                                      IOException {
        List<String> lstGroupIsMember = new ArrayList<String>();
        ManageGroup objWeblogicGroup = new ManageGroup();
        for (Map<String, Object> group : listGroup) {
            boolean isMember =
                objWeblogicGroup.isMember((String)group.get("0"), username,
                                          true);
            if (isMember) {
                lstGroupIsMember.add((String)group.get("0"));
            }
        }
        ManageWeblogic.close();
        return lstGroupIsMember;
    }

    public void updatePermission(ValueChangeEvent valueChangeEvent) {
        String member = txtTenDangNhapUpdate.getValue().toString();
        ManageGroup objWeblogicGroup = new ManageGroup();
        List<String> lstOldValue =
            (List<String>)valueChangeEvent.getOldValue();
        List<String> lstNewValue =
            (List<String>)valueChangeEvent.getNewValue();
        if (lstOldValue == null) {
            lstOldValue = new ArrayList();
        }
        if (lstNewValue == null) {
            lstNewValue = new ArrayList();
        }

        List<String> listDelte = new ArrayList<String>();
        List<String> listAdd = new ArrayList<String>();
        for (String item : lstOldValue) {
            if (lstNewValue.contains(item) == false) {
                listDelte.add(item);
            }
        }
        for (String item : lstNewValue) {
            if (lstOldValue.contains(item) == false) {
                listAdd.add(item);
            }
        }
        if (listDelte.size() > 0) {
            for (String str : listDelte) {
                try {
                    objWeblogicGroup.removeMemberFromGroup(str, member);
                } catch (Exception e) {
                    Utils.showMessage(Utils.MSG_ERROR, e.getMessage());
                    e.printStackTrace();
                }
            }
        }
        if (listAdd.size() > 0) {
            for (String str : listAdd) {
                try {
                    objWeblogicGroup.addMemberToGroup(str, member);
                } catch (Exception e) {
                    Utils.showMessage(Utils.MSG_ERROR, e.getMessage());
                    e.printStackTrace();
                }
            }
        }
        ManageWeblogic.close();
    }

    public void addNewUser(DialogEvent dialogEvent) {
        if (dialogEvent.getOutcome().compareTo(DialogEvent.Outcome.ok) == 0) {
            String txtTenDangNhap =
                this.txtTenDangNhap.getValue().toString().trim();
            String txtChuThich = "";
            String txtDisplayname = "";
            String txtMail = "";
            String txtMobile = "";
            String txtDepartmentnumber = "";
            String txtTitle = "";
            boolean inputErr = false;

            if (this.txtChuThich.getValue() != null) {
                txtChuThich = this.txtChuThich.getValue().toString();
            }

            String txtMatKhau = this.txtMatKhau.getValue().toString();
            String txtNhapLaiMatKhau =
                this.txtNhapLaiMatKhau.getValue().toString();
            if (!validateField(txtMatKhau, txtNhapLaiMatKhau)) {
                //chua viet ham nay
                inputErr = true;
            }
            objWeblogicUser = new ManageUser();
            objWeblogicUserAttribute = new ManageUserAttribute();
            if (!inputErr) {
                try {

                    //                    boolean checkExist =
                    //                        objWeblogicUser.userExists(txtTenDangNhap);
                    if (validateUsername(txtTenDangNhap)) {
                        objWeblogicUser.createUser(txtTenDangNhap, txtMatKhau,
                                                   txtChuThich);
                        //User của riêng SSC, trường hợp này dùng để không load các user khác ngoài SSC
                        objWeblogicUser.setUserAttributeValue(objWeblogicUserAttribute.connection,
                                                              objWeblogicUserAttribute.service,
                                                              txtTenDangNhap,
                                                              "employeetype",
                                                              ssc);
                        if (this.txtDisplayname.getValue() != null) {
                            txtDisplayname =
                                    this.txtDisplayname.getValue().toString();
                            objWeblogicUser.setUserAttributeValue(objWeblogicUserAttribute.connection,
                                                                  objWeblogicUserAttribute.service,
                                                                  txtTenDangNhap,
                                                                  "displayname",
                                                                  txtDisplayname);
                        }

                        if (this.txtMail.getValue() != null) {
                            txtMail = this.txtMail.getValue().toString();
                            objWeblogicUser.setUserAttributeValue(objWeblogicUserAttribute.connection,
                                                                  objWeblogicUserAttribute.service,
                                                                  txtTenDangNhap,
                                                                  "mail",
                                                                  txtMail);
                        }

                        if (this.txtMobile.getValue() != null) {
                            txtMobile = this.txtMobile.getValue().toString();
                            objWeblogicUser.setUserAttributeValue(objWeblogicUserAttribute.connection,
                                                                  objWeblogicUserAttribute.service,
                                                                  txtTenDangNhap,
                                                                  "mobile",
                                                                  txtMobile);
                        }

                        if (this.txtDepartmentnumber.getValue() != null) {
                            txtDepartmentnumber =
                                    this.txtDepartmentnumber.getValue().toString();
                            objWeblogicUser.setUserAttributeValue(objWeblogicUserAttribute.connection,
                                                                  objWeblogicUserAttribute.service,
                                                                  txtTenDangNhap,
                                                                  "departmentnumber",
                                                                  txtDepartmentnumber);
                        }

                        if (this.txtTitle.getValue() != null) {
                            txtTitle = this.txtTitle.getValue().toString();
                            objWeblogicUser.setUserAttributeValue(objWeblogicUserAttribute.connection,
                                                                  objWeblogicUserAttribute.service,
                                                                  txtTenDangNhap,
                                                                  "title",
                                                                  txtTitle);
                        }
                        ManageWeblogic.close();
                        objWeblogicUser = null;
                        //refresh lai du lieu tren table
                        refresh();

                        //thông báo tạo mới user thành công
                        Utils.showMessage(Utils.MSG_INFO,
                                          "Tạo mới người dùng: " +
                                          txtTenDangNhap + " thành công.");
                    }
                    //                    else {
                    //                        Utils.showMessage(Utils.MSG_ERROR,
                    //                                          "Đã tồn tại người dùng: " +
                    //                                          txtTenDangNhap);
                    //                    }


                } catch (Exception e) {
                    Utils.showMessage(Utils.MSG_ERROR, e.getMessage());
                    e.printStackTrace();
                }
                //xoa toan bo gia tri tren form nhap
                resetFormValue();
            }


        }
    }

    public void removeUser(DialogEvent dialogEvent) {
        if (dialogEvent.getOutcome().compareTo(DialogEvent.Outcome.ok) == 0) {
            Map<String, Object> lstTemp =
                (Map<String, Object>)this.getTable().getSelectedRowData();

            objWeblogicUser = new ManageUser();
            try {
                objWeblogicUser.removeUser(lstTemp.get("0").toString());
                refresh();
                ManageWeblogic.close();
            } catch (Exception e) {
                Utils.showMessage(Utils.MSG_ERROR, e.getMessage());
                e.printStackTrace();
            }
        }
    }

    public boolean validateField(String pass, String repass) {
        if (!pass.equals(repass)) {
            Utils.showMessage(Utils.MSG_ERROR, "Mật khẩu không trùng nhau.");
        } else {
            if (pass.length() < 9) {
                Utils.showMessage(Utils.MSG_ERROR,
                                  "Mật khẩu không được nhỏ hơn 9 ký tự.");
            } else {
                return true;
            }
        }
        return false;
    }

    public boolean validateFieldUpdate(String pass, String newpass) {
        if (pass.equals(newpass)) {
            Utils.showMessage(Utils.MSG_ERROR, "Mật mới và cũ không trùng .");
        } else {
            if (newpass.length() < 9) {
                Utils.showMessage(Utils.MSG_ERROR,
                                  "Mật khẩu không được nhỏ hơn 9 ký tự.");
            } else {
                return true;
            }
        }
        return false;
    }

    public boolean validateUsername(String username) {
        boolean b = true;
        if (username.contains(" ")) {
            Utils.showMessage(Utils.MSG_ERROR,
                              "Tên đăng nhập không chứa ký tự trắng");
            b = false;
        }
        try {
            boolean isexist = objWeblogicUser.userExists(username);
            if (isexist) {
                Utils.showMessage(Utils.MSG_ERROR,
                                  "Đã tồn tại người dùng: " + username);
                b = false;
            }
        } catch (InstanceNotFoundException e) {
            e.printStackTrace();
            b = false;
        } catch (MBeanException e) {
            e.printStackTrace();
            b = false;
        } catch (ReflectionException e) {
            e.printStackTrace();
            b = false;
        } catch (IOException e) {
            e.printStackTrace();
            b = false;
        }
        return b;
    }


    private void refresh() {
        getListUsers();
    }

    private RichSelectManyShuttle selectManyShuttle =
        new RichSelectManyShuttle();
    private RichTable table = new RichTable();
    private RichPopup popup = new RichPopup();
    private RichPanelTabbed tab = new RichPanelTabbed();

    private RichInputText txtTenDangNhap = new RichInputText();
    private RichInputText txtChuThich = new RichInputText();
    private RichInputText txtMatKhau = new RichInputText();
    private RichInputText txtNhapLaiMatKhau = new RichInputText();

    private RichInputText txtDisplayname = new RichInputText();
    private RichInputText txtMail = new RichInputText();
    private RichInputText txtMobile = new RichInputText();
    private RichInputText txtDepartmentnumber = new RichInputText();
    private RichInputText txtTitle = new RichInputText();

    private RichInputText txtTenDangNhapUpdate = new RichInputText();
    private RichInputText txtChuThichUpdate = new RichInputText();
    private RichInputText txtMatKhauUpdate = new RichInputText();
    private RichInputText txtNhapLaiMatKhauUpdate = new RichInputText();

    private RichInputText txtDisplaynameUpdate = new RichInputText();
    private RichInputText txtMailUpdate = new RichInputText();
    private RichInputText txtMobileUpdate = new RichInputText();
    private RichInputText txtDepartmentnumberUpdate = new RichInputText();
    private RichInputText txtTitleUpdate = new RichInputText();
    
    private RichPopup popupUserInfo;
    private RichPanelTabbed userInfotab;
    private RichInputText txtChuthichInfo;
    private RichInputText txtHovatenInfo;
    private RichInputText txtEmailInfo;
    private RichInputText txtDepartmentInfo;
    private RichInputText txtTitleInfo;
    private RichInputText txtMobileInfo;
    
    

    public void setTable(RichTable table) {
        this.table = table;
    }

    public RichTable getTable() {
        return table;
    }

    public void setPopup(RichPopup popup) {
        this.popup = popup;
    }

    public RichPopup getPopup() {
        return popup;
    }

    public void setTab(RichPanelTabbed tab) {
        this.tab = tab;
    }

    public RichPanelTabbed getTab() {
        return tab;
    }

    public void setTxtTenDangNhap(RichInputText txtTenDangNhap) {
        this.txtTenDangNhap = txtTenDangNhap;
    }

    public RichInputText getTxtTenDangNhap() {
        return txtTenDangNhap;
    }

    public void setTxtChuThich(RichInputText txtChuThich) {
        this.txtChuThich = txtChuThich;
    }

    public RichInputText getTxtChuThich() {
        return txtChuThich;
    }

    public void setTxtMatKhau(RichInputText txtMatKhau) {
        this.txtMatKhau = txtMatKhau;
    }

    public RichInputText getTxtMatKhau() {
        return txtMatKhau;
    }

    public void setTxtNhapLaiMatKhau(RichInputText txtNhapLaiMatKhau) {
        this.txtNhapLaiMatKhau = txtNhapLaiMatKhau;
    }

    public RichInputText getTxtNhapLaiMatKhau() {
        return txtNhapLaiMatKhau;
    }


    public void setTxtDisplayname(RichInputText txtDisplayname) {
        this.txtDisplayname = txtDisplayname;
    }

    public RichInputText getTxtDisplayname() {
        return txtDisplayname;
    }

    public void setTxtMail(RichInputText txtMail) {
        this.txtMail = txtMail;
    }

    public RichInputText getTxtMail() {
        return txtMail;
    }

    public void setTxtMobile(RichInputText txtMobile) {
        this.txtMobile = txtMobile;
    }

    public RichInputText getTxtMobile() {
        return txtMobile;
    }

    public void setTxtDepartmentnumber(RichInputText txtDepartmentnumber) {
        this.txtDepartmentnumber = txtDepartmentnumber;
    }

    public RichInputText getTxtDepartmentnumber() {
        return txtDepartmentnumber;
    }

    public void setTxtTitle(RichInputText txtTitle) {
        this.txtTitle = txtTitle;
    }

    public RichInputText getTxtTitle() {
        return txtTitle;
    }

    public void setSelectManyShuttle(RichSelectManyShuttle selectManyShuttle) {
        this.selectManyShuttle = selectManyShuttle;
    }

    public RichSelectManyShuttle getSelectManyShuttle() {
        return selectManyShuttle;
    }

    public void setTxtChuThichUpdate(RichInputText txtChuThichUpdate) {
        this.txtChuThichUpdate = txtChuThichUpdate;
    }

    public RichInputText getTxtChuThichUpdate() {
        return txtChuThichUpdate;
    }

    public void setTxtMatKhauUpdate(RichInputText txtMatKhauUpdate) {
        this.txtMatKhauUpdate = txtMatKhauUpdate;
    }

    public RichInputText getTxtMatKhauUpdate() {
        return txtMatKhauUpdate;
    }

    public void setTxtNhapLaiMatKhauUpdate(RichInputText txtNhapLaiMatKhauUpdate) {
        this.txtNhapLaiMatKhauUpdate = txtNhapLaiMatKhauUpdate;
    }

    public RichInputText getTxtNhapLaiMatKhauUpdate() {
        return txtNhapLaiMatKhauUpdate;
    }

    public void setTxtDisplaynameUpdate(RichInputText txtDisplaynameUpdate) {
        this.txtDisplaynameUpdate = txtDisplaynameUpdate;
    }

    public RichInputText getTxtDisplaynameUpdate() {
        return txtDisplaynameUpdate;
    }

    public void setTxtMailUpdate(RichInputText txtMailUpdate) {
        this.txtMailUpdate = txtMailUpdate;
    }

    public RichInputText getTxtMailUpdate() {
        return txtMailUpdate;
    }

    public void setTxtMobileUpdate(RichInputText txtMobileUpdate) {
        this.txtMobileUpdate = txtMobileUpdate;
    }

    public RichInputText getTxtMobileUpdate() {
        return txtMobileUpdate;
    }

    public void setTxtDepartmentnumberUpdate(RichInputText txtDepartmentnumberUpdate) {
        this.txtDepartmentnumberUpdate = txtDepartmentnumberUpdate;
    }

    public RichInputText getTxtDepartmentnumberUpdate() {
        return txtDepartmentnumberUpdate;
    }

    public void setTxtTitleUpdate(RichInputText txtTitleUpdate) {
        this.txtTitleUpdate = txtTitleUpdate;
    }

    public RichInputText getTxtTitleUpdate() {
        return txtTitleUpdate;
    }

    public void setTxtTenDangNhapUpdate(RichInputText txtTenDangNhapUpdate) {
        this.txtTenDangNhapUpdate = txtTenDangNhapUpdate;
    }

    public RichInputText getTxtTenDangNhapUpdate() {
        return txtTenDangNhapUpdate;
    }


    public void setPopupUserInfo(RichPopup popupUserInfo) {
        this.popupUserInfo = popupUserInfo;
    }

    public RichPopup getPopupUserInfo() {
        return popupUserInfo;
    }

    public void setUserInfotab(RichPanelTabbed userInfotab) {
        this.userInfotab = userInfotab;
    }

    public RichPanelTabbed getUserInfotab() {
        return userInfotab;
    }


    public void setTxtChuthichInfo(RichInputText txtChuthichInfo) {
        this.txtChuthichInfo = txtChuthichInfo;
    }

    public RichInputText getTxtChuthichInfo() {
        return txtChuthichInfo;
    }

    public void setTxtHovatenInfo(RichInputText txtHovatenInfo) {
        this.txtHovatenInfo = txtHovatenInfo;
    }

    public RichInputText getTxtHovatenInfo() {
        return txtHovatenInfo;
    }

    public void setTxtEmailInfo(RichInputText txtEmailInfo) {
        this.txtEmailInfo = txtEmailInfo;
    }

    public RichInputText getTxtEmailInfo() {
        return txtEmailInfo;
    }

    public void setTxtDepartmentInfo(RichInputText txtDepartmentInfo) {
        this.txtDepartmentInfo = txtDepartmentInfo;
    }

    public RichInputText getTxtDepartmentInfo() {
        return txtDepartmentInfo;
    }

    public void setTxtTitleInfo(RichInputText txtTitleInfo) {
        this.txtTitleInfo = txtTitleInfo;
    }

    public RichInputText getTxtTitleInfo() {
        return txtTitleInfo;
    }

    public void setTxtMobileInfo(RichInputText txtMobileInfo) {
        this.txtMobileInfo = txtMobileInfo;
    }

    public RichInputText getTxtMobileInfo() {
        return txtMobileInfo;
    }

    public void setTxtMatKhauReset(RichInputText txtMatKhauReset) {
        this.txtMatKhauReset = txtMatKhauReset;
    }

    public RichInputText getTxtMatKhauReset() {
        return txtMatKhauReset;
    }
}
